package com.benyanyi.okhttp.call;

import android.content.Context;

import com.benyanyi.okhttp.config.CallType;

import okhttp3.Call;

/**
 * @author YanYi
 * @date 2019-08-12 15:46
 * @email ben@yanyi.red
 * @overview
 */
class CallBuilder {
    private CallType callType;
    private Call call;
    private boolean isCache;//是否需要缓存
    private String mCacheName;//缓存名称
    private Context context;

    CallBuilder setCallType(CallType callType) {
        this.callType = callType;
        return this;
    }

    CallBuilder setCall(Call call) {
        this.call = call;
        return this;
    }

    CallBuilder setCache(boolean cache) {
        isCache = cache;
        return this;
    }

    CallBuilder setCacheName(String mCacheName) {
        this.mCacheName = mCacheName;
        return this;
    }

    CallBuilder setContext(Context context) {
        this.context = context;
        return this;
    }

    CallType getCallType() {
        return callType;
    }

    Call getCall() {
        return call;
    }

    boolean isCache() {
        return isCache;
    }

    String getCacheName() {
        return mCacheName;
    }

    Context getContext() {
        return context;
    }

    ObjectCall builder() {
        return new ObjectCall(this);
    }

    <T> BeanCall<T> builder(Class<T> tClass) {
        return new BeanCall<>(this, tClass);
    }

    <T> ListCall<T> listBuilder(Class<T> tClass) {
        return new ListCall<>(this, tClass);
    }
}
